package com.ky.server.service;

import com.ky.common.dto.Dto;
import com.ky.common.entity.KyUser;
import com.ky.server.dao.UserDao;

public class RegisterService implements Service<KyUser>{

	@Override
	public Dto service(KyUser data) {
		
		Dto<Object> responseDto = new Dto<>();
		KyUser xmlUser = UserDao.getUserByName(data.getUserName());
		if(xmlUser==null) {
			UserDao.addUser(data);
			responseDto.setCode(200);
		}else {
			responseDto.setCode(10001);
			responseDto.setErrorMsg("用户名已存在，不能重新注册！");
		}
		return responseDto;
	}

}
